<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="js/vue.js"></script>
</head>

<body>
  <div id="app">
    <p v-show="age >= 18">成年</p>
    <p v-show="age < 18">未成年</p>

    <p v-if="age >= 18">成年</p>
    <p v-if="age < 18">未成年</p>

    <hr>

    <p v-if="salary <=10">普通阶层</p>
    <p v-else-if="salary <=500">中产阶层</p>
    <p v-else="salary >500">富豪阶层</p>
    <hr>
    <!--
       类似java中的foreach in 后面就是集合， o（object）代表每次遍历的当前值 
      i（index）代表当前索引值，注意顺序,o代表当前内容
    -->
    <p v-for="o in hobby ">{{o}}</p>
    <p v-for="o,i in hobby ">{{i}}--{{o}}</p>
    <hr>
    <!-- v-on:click 缩写是@click -->
    <button @click="show()">点我</button>
    <button v-on:click="show()">点我</button>
    <button v-on:click="show">点我</button>
  </div>

  <script>
    var vm = new Vue({
      el: '#app',
      data: {
        age: 18,
        salary: 9,
        hobby: ["乒乓", "爬山", "唱歌"]
      },
      methods: {
        show: function () {
          console.log("show method");
        }
      }
    });
  </script>
</body>

</html>